<template>
  <tr>
    <td>
      <input type="checkbox" v-model="obj.checked" />
    </td>
    <td>{{ obj.name }}</td>
    <td>{{ obj.price }}</td>
    <td>
      <button @click="decrement" :disabled="obj.num<=1">-</button>
      <span>{{ obj.num }}</span>
      <button @click="increment">+</button>
    </td>
    <td>{{ obj.price * obj.num }}</td>
    <td>
      <button @click="removeHandler">删除</button>
    </td>
  </tr>
</template>

<script>
export default {
  props: ["obj","index"],
  methods: {
    decrement() {
      this.obj.num--;
    },
    increment() {
      this.obj.num++;
    },
    removeHandler(){
      this.$emit('sub',this.index)
    }
  },
};
</script>

<style>
</style>